﻿using System;
using System.Collections.Generic;
using System.Text;
using TTEngine.TTMath;

namespace TTEngine.Framework.UI
{
    public class UICustomRender : UIBaseElement
    {
        public delegate void deleOnCustomUpdate(float delta, UICanvas canvas, fAABB dest);
        public delegate void deleOnCustomRender(UICanvas canvas, fAABB dest);
        public delegate bool deleOnCustomTouch(int touchid, bool press, bool move, float x, float y);

        public deleOnCustomUpdate OnCustomUpdate;
        public deleOnCustomRender OnCustomRender;
        public deleOnCustomTouch OnCustomTouch;

        public override void OnRender(UICanvas canvas)
        {
            OnCustomRender?.Invoke(canvas, this.GetWorldRect());
        }
        public override void OnUpdate(UICanvas canvas, float delta)
        {
            OnCustomUpdate?.Invoke(delta, canvas, this.GetWorldRect());
        }
        public override bool OnTouch(UICanvas canvas, int touchId, bool press, bool move, float x, float y)
        {
            if (OnCustomTouch == null)
                return false;
            return OnCustomTouch(touchId, press, move, x, y);
        }

    }
}
